<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>10-sessionStorage</title>
</head>
<body>


<button onclick="fn1()">设置sessionStorage</button>
<button onclick="fn2()">获取sessionStorage</button>
<button onclick="fn3()">清空sessionStorage</button>
从
</body>
<script>

    /**
     * 设置sessionStorage
     */
    function fn1() {
        sessionStorage.setItem("msg","helloworld");
    }

    /**
     * 获取sessionStorage
     */
    function fn2() {
        var msg = sessionStorage.getItem("msg");
        console.log("msg = " + msg)
    }

    /**
     * 清空sessionStorage
     */
    function fn3() {
        sessionStorage.removeItem("msg");
    }

</script>
</html>